home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
challenge
/
13.09
/
ChallengeTuring.sit.hqx
/
Challenge, Turing
/
Turing.h
< prev
next >
Wrap
Text File
|
1997-06-19
|
1KB
|
44 lines
// Turing.h
#pragma once
#include <Types.h>
#ifdef USE_C
#ifdef __cplusplus
extern "C" {
#endif
#endif
typedef unsigned long ulong;
typedef enum {kMoveLeft=-1,kHalt=0, kMoveRight=1} MoveDir;
typedef struct TMRule { /* rule in program for TM */
ulong oldState; /* this rule fires when currentState == oldState and */
ulong inputSymbol; /* currentSymbol == inputSymbol */
ulong newState; /* set currentState to newState when this rule fires */
ulong outputSymbol; /* write outputSymbol to tape when this rule fires */
MoveDir moveDirection; /* move left or right as indicated when this rule fires */
} TMRule;
typedef void (*TMMoveProc) (
ulong outputSymbol,
ulong newState,
MoveDir moveDirection
);
Boolean /* success */ TuringMachine(
const TMRule theRules[], /* pointer to program for TM */
ulong numRules, /* number of rules in TM program */
ulong *theTape, /* pointer to input tape for TM */
ulong tapeLen, /* theTape[0]..theTape[tapeLen-1] is valid */
long rwHeadPos, /* TM read head is at theTape[rwHeadPos] */
TMMoveProc ReportMove /* callback proc to inform caller of each move */
);
#ifdef USE_C
#ifdef __cplusplus
}
#endif
#endif